package com.agricultural.state;

import com.agricultural.equipment.AgriculturalEquipment;

// 低油量状态
public class LowFuelState implements EquipmentState {
    private AgriculturalEquipment equipment;

    public LowFuelState(AgriculturalEquipment equipment) {
        this.equipment = equipment;
    }

    @Override
    public void start(AgriculturalEquipment equipment) {
        System.out.println(equipment.getEquipmentId() + " 燃油不足，无法启动");
    }

    @Override
    public void stop(AgriculturalEquipment equipment) {
        System.out.println(equipment.getEquipmentId() + " 已停止，等待加油");
        equipment.setState(new IdleState(equipment));
    }

    @Override
    public void performTask(AgriculturalEquipment equipment) {
        System.out.println(equipment.getEquipmentId() + " 燃油不足，无法执行任务");
    }

    @Override
    public void handleEmergency(AgriculturalEquipment equipment, String emergencyType) {
        System.out.println(equipment.getEquipmentId() + " (低油量状态) 收到紧急情况: " + emergencyType);

        if ("refueled".equalsIgnoreCase(emergencyType)) {
            System.out.println(equipment.getEquipmentId() + " 已加满油，准备就绪");
            equipment.setState(new IdleState(equipment));
        }
    }

    @Override
    public String getStateName() {
        return "低油量";
    }
}